package com.educhains.module.demo.service.impl;

import com.educhains.module.demo.persist.mybatis.DemoMapper;
import com.educhains.module.demo.service.DemoService;
import com.educhains.module.demo.vo.Demo;
import com.educhains.module.demo.vo.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author YuRun
 * @since 2017年8月16日
 */
@Service
public class DemoServiceImpl implements DemoService {

    @Autowired
    private DemoMapper demoMapper = null;

    /**
     * Get Demo Page
     *
     * @return
     */
    public Page showByPage(int pageNum) {

        //一页能容纳的最多Demo数量
        int totalRecord = demoMapper.getAllDemos();
        Page page = new Page(pageNum, totalRecord);
        List list = demoMapper.showByPage(page.getStartIndex(), page.getPageSize());
        page.setList(list);
        return page;
    }
}
